﻿using System;
using System.Collections.Generic;
using System.Text;


namespace Daco.Security
{
    using Daco.Security.Providers;

    public sealed class CRole
    {
        public static string[] FindUsersInRole(string roleName, string usernameToMatch)
        {
            return CRoleProvider.Instance.FindUsersInRole(roleName, usernameToMatch);
        }
        //
        // Summary:
        //     Gets a list of all the roles
        //
        // Returns:
        //     A string array containing the names of all the roles stored in the data source
        public static string[] GetAllRoles()
        {
            return CRoleProvider.Instance.GetAllRoles();
        }
        //
        // Summary:
        //     Gets a list of the roles that a specified user is in
        //
        // Parameters:
        //   username:
        //     The user to return a list of roles for.
        //
        // Returns:
        //     A string array containing the names of all the roles that the specified user
        //     is in
        public static string[] GetRolesForUser(string username)
        {
            return CRoleProvider.Instance.GetRolesForUser(username);
        }
        //
        // Summary:
        //     Gets a list of users in the specified role
        //
        // Parameters:
        //   roleName:
        //     The name of the role to get the list of users for.
        //
        // Returns:
        //     A string array containing the names of all the users who are members of the
        //     specified role
        public static string[] GetUsersInRole(string roleName)
        {
            return CRoleProvider.Instance.GetUsersInRole(roleName);
        }
        //
        // Summary:
        //     Gets a value indicating whether the specified user is in the specified role
        //
        // Parameters:
        //   username:
        //     The user name to search for.
        //
        //   roleName:
        //     The role to search in.
        //
        // Returns:
        //     true if the specified user is in the specified role for the configured applicationName;
        //     otherwise, false.
        public static bool IsUserInRole(string username, string roleName)
        {
            return CRoleProvider.Instance.IsUserInRole(username, roleName);
        }

        //
        // Summary:
        //     Gets a value indicating whether the specified role name already exists in
        //     the role data source
        //
        // Parameters:
        //   roleName:
        //     The name of the role to search for in the data source.
        //
        // Returns:
        //     true if the role name already exists in the data source otherwise, false.
        public static bool RoleExists(string roleName)
        {
            return CRoleProvider.Instance.RoleExists(roleName);
        }
    }
}
